<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ProductManage extends CI_Controller {
	
	public function index(){
		$this->cismarty->assign('baseUrl',$this->config->item('base_url'));
		
		$this->load->model('Product');
		$productList=$this->Product->getProductList();
		$this->cismarty->assign('dataList',$productList);
		
		$this->cismarty->display('product/main.tpl');
	}
	
	public function create(){
		$this->load->model('Product');
		$arr=array('name'=>$_POST['name'],'content'=>$_POST['content']);
		$this->Product->createProduct($arr);
		self::index();
	}
	
	public function createInit(){
		$this->cismarty->assign('baseUrl',$this->config->item('base_url')); 
		$this->cismarty->display('product/createProduct.tpl');
	}
	
	public function update(){
			$this->load->model('Product');
			$arr=array('name'=>$_POST['name']);
			$id=$_POST['id'];
			$this->Product->updateProductInfo($id,$arr);
			self::index();
	}
	
	public function updateInit(){
			$this->load->model('Product');
			$dataInfo=$this->Product->getProductInfoById($_GET['id']);
			$this->cismarty->assign('dataInfo',$dataInfo);
			
			$this->cismarty->assign('baseUrl',$this->config->item('base_url')); 
			$this->cismarty->display('product/updateProduct.tpl');
	}
	public function delete(){
		$this->load->model('Product');
		$id=$_GET['id'];
		$this->Product->deleteProductInfoById($id);
		self::index();
	}

}
	

